//
//  GWGeneralSettingController.m
//  新浪微博
//
//  Created by qianfeng on 16/2/25.
//  Copyright (c) 2016年 高炜. All rights reserved.
//

#import "GWGeneralSettingController.h"
#import "GWDiscoverItemGroup.h"
#import "GWDiscoverItem.h"
#import "GWDiscoverCell.h"
#import "GWCommonIArrowtem.h"
#import "GWCommonSwitchItem.h"
#import "GWCommonLabelItem.h"
#import "MBProgressHUD+MJ.h"
#import "SDImageCache.h"
#import "NSString+fileSize.h"
@interface GWGeneralSettingController ()

@end

@implementation GWGeneralSettingController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addGroup0];
    // Do any additional setup after loading the view.
}
-(void)addGroup0
{
    GWDiscoverItemGroup *group =[[GWDiscoverItemGroup alloc]init];
    
    GWCommonLabelItem *account =[GWCommonLabelItem itemWithTitle:@"阅读模式"];
    account.labelText =@"有图模式";
    GWCommonLabelItem *font =[GWCommonLabelItem itemWithTitle:@"字号大小"];
    font.labelText =@"大";
    GWCommonSwitchItem *beizhu =[GWCommonSwitchItem itemWithTitle:@"显示备注"];
    
    GWCommonIArrowtem *clearCache =[GWCommonIArrowtem itemWithTitle:@"清除缓存"];
    NSString *path =[SDImageCache sharedImageCache].diskCachePath;
    clearCache.subleTitle =[NSString stringWithFormat:@"(%.1f M)",[path fileSize]/(1024.0*1024.0)];
    __weak typeof(clearCache) weakCache =clearCache;
    __weak typeof (self) weakSelf =self;
    [clearCache setOperation:^{
        
        [MBProgressHUD showMessage:@"正在清理缓存..."];
        
        NSFileManager *fm =[NSFileManager defaultManager];
        [fm removeItemAtPath:path error:nil];
        weakCache.subleTitle=nil;
        [weakSelf.tableView reloadData];
        
        [MBProgressHUD hideHUD];
    }];
    
    group.items =@[account,font,beizhu,clearCache];
    [self.itemGroups addObject:group];
}

@end
